﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ThermostatMonitorLib
{
    public class Weather
    {
        public static int GetTemperature(string zipCode)
        {
            string url = "http://www.google.com/ig/api?weather=" + zipCode;
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(url);
            System.Xml.XmlNodeList nodes = doc.SelectNodes("/xml_api_reply/weather/current_conditions/temp_f");
            return Convert.ToInt32(nodes[0].Attributes["data"].Value);
        }
    }
}
